Writing a replacement for Hugo with Junie

In a previous post about My Tentative Steps in AI Programming, I mentioned that I was going to try leveraging AI to build a program to replace Hugo in my blog workflow. Well after several months, moving to another state, and starting a new job; I've just put the finishing touches on it! I'd like to introduce you to Markdown-to-HTML!1 In less than 500 lines of Python2, it can take an entire directory of markdown and Jinja2 templates and spit out a fully functional static website. The ethos behind it is that I wanted everything to exist where it will be used. I didn't want to fuss with dedicated directories for templates and static files and themes and archetypes and whatever other weird words you want to come up with for simple ideas. It grinds my gears a bit to see the directory structure of my desired website repeated in several places for no good reason. And lord help you if you forget to add that new directory to you content folder, template folder, AND theme folder! So no more of that! Where is my css? Wherever the hell I want it to be! As long as my template points to the right location, it'll work! Not only that but there's a tiered system for selecting what template to use. And these templates exist side by side with all your markdown files and static content.

How AI helped

Junie really helped get me started. What would have been days of researching and learning about Python-Markdown and Jinja2 and all the alternatives, was trimmed down to an afternoon. My first step was more akin to vibe coding than AI assisted development. I gave Junie broad instructions about what I wanted and she banged out some Python in a jiffy. I hadn't even done any research into what packages might be useful for the task so I was pleasantly surprised to see Junie pulling in python-markdown and pyyaml. While the program ran and fulfilled the basic requirements, I didn't feel secure about using packages without at least making sure they were still maintained. Thankfully, everything looked good. I even checked into possible alternatives and found nothing I would want to switch them out for.

Once the program started to grow, pain points started popping up. The doctstrings and unit tests that Junie so helpfully created as she went quickly became outdated and even broken. She wouldn't remember to update them on her own. And when I reminded her, she would slap a band-aid on it without looking to see if a refactoring was due or if the test even made sense anymore. I also noticed she made a dictionary at some point that never got used and decided to check that the output directory was valid for every single file that got processed...

So at some point I had to put the AI aside and do some detangling the old fashioned way. I combed through every line and made changes here and there. The finished program actually looks nothing like what Junie originally spun up. Some might point to this and say that I would've saved time just writing it from scratch to begin with. I don't think that's the case though. There's many things in there that would've taken me a long time to even think to implement. By profession, I'm a .Net developer. I only use Python for side projects so I'm much less familiar with what packages are available and what's the proper way to format a project. In fact, I once tried to make exactly this kind of project to use for my blog before deciding it was just too much work and settling on Hugo. The reason I thought that is because I was trying to parse the markdown into HTML myself! It didn't even occur to me to check for a package on PyPI that could do that for me! Perhaps I could've done it faster on my own if I had known about python-markdown but the whole thing felt out of reach as an after-work project without Junie to help me. So while I potentially could have, I didn't even want to try because of the perceived difficulty of the project. Junie gave me the courage to give it a shot.

Conclusion

Vibe coding with AI is a great way to jump start a project. If you suffer from blank page syndrome or feel overwhelmed by choice when researching what packages to use, it's a fantastic tool. However, this should be treated as a first draft. You should be prepared to completely rewrite it once you have a better idea of where you're going and how you want the program laid out. Also, it can come up with some really weird ways of doing things if you aren't VERY specific about what you want and how you want it done. After that initial phase, AI can still be useful in small bursts. A great example task for an AI is when you have a bit of code that you want refactored a certain way but it would be long and tedious to do yourself. Another is for doing preliminary research into what's available for you to use. I actually did just that to decide on a templating language before I even created the repository.


  1. The name might change soon. I'm considering putting it up on PyPI to make it easier for others to find and use it but many of the sensible names are already taken. 

  2. That will probably change soon. I have some ideas to add.